package com.zzxy.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
@Aspect
public class MyAspect {
    @Pointcut("execution(* com.zzxy.service..*.*(int))")
    public void myPointcut() {
    }
    @Before("myPointcut()")
    public void myBefore(JoinPoint joinPoint) {
        System.out.println("before :" + joinPoint.getSignature().getName());
    }
@After("myPointcut()")
    public void myAfter(JoinPoint joinPoint) {
        System.out.println("after ..");
    }
    @AfterReturning(pointcut = "myPointcut()",returning = "ret")
    public Object myAfterReturing(JoinPoint joinPoint,Object ret) {
        System.out.println("afterreturing .."+ret);
        return  ret;
    }
    @AfterThrowing(pointcut = "myPointcut()",throwing = "e")
    public void myThrowable(JoinPoint joinPoint, Throwable e) {
        System.out.println("my throwable；"+e);
    }

    public void myAround(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("1.aroud before  ");
        pjp.proceed();
        System.out.println("2.aroud after  ");

    }
}
